/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    height: 450px;
    overflow: hidden;
}

/* Main container - fits within iframe constraints */
.container {
    width: 100%;
    height: 450px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Government branches layout */
.branches-container {
    display: flex;
    gap: 10px;
    height: 180px;
    flex-shrink: 0;
}

/* Individual branch styling */
.branch {
    flex: 1;
    background: #ffffff;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.branch:hover,
.branch:focus {
    border-color: #4a90e2;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
    outline: none;
}

/* Branch header with icon and title */
.branch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.branch-header h2 {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
}

.branch-icon {
    font-size: 20px;
}

/* Branch description text */
.branch-description {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.3;
}

/* Drop zones for functions */
.drop-zone {
    min-height: 80px;
    border: 2px dashed #bdc3c7;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.drop-zone.drag-over {
    border-color: #27ae60;
    background: #e8f5e8;
    transform: scale(1.02);
}

.drop-hint {
    color: #95a5a6;
    font-size: 10px;
    text-align: center;
    margin-top: 20px;
    font-style: italic;
}

/* Functions panel */
.functions-panel {
    background: #ffffff;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #e0e6ed;
    height: 140px;
    overflow-y: auto;
}

.functions-panel h3 {
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 8px;
    text-align: center;
}

.functions-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px;
}

/* Function cards - draggable items */
.function-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    user-select: none;
}

.function-card:hover,
.function-card:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.function-card:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.function-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.function-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.function-text {
    line-height: 1.2;
    font-weight: 500;
}

/* Dropped function cards in branches */
.dropped-function {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    color: #2c3e50;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    animation: dropIn 0.3s ease-out;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Feedback section */
.feedback-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e0e6ed;
    height: 50px;
    flex-shrink: 0;
}

/* Progress bar */
.progress-bar {
    flex: 1;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #56ab2f 0%, #a8e6cf 100%);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

/* Feedback message */
.feedback-message {
    font-size: 12px;
    color: #2c3e50;
    font-weight: 500;
    min-width: 200px;
}

/* Reset button */
.reset-button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.reset-button:hover,
.reset-button:focus {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Success animation */
.success-animation {
    animation: celebrate 0.6s ease-out;
}

@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Accessibility improvements */
.function-card:focus,
.branch:focus,
.reset-button:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .branches-container {
        flex-direction: column;
        height: auto;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .branch {
        min-height: 120px;
    }
    
    .functions-container {
        grid-template-columns: 1fr;
    }
    
    .feedback-section {
        flex-direction: column;
        height: auto;
        gap: 5px;
    }
}